package application.controller;

import application.ATM;
import application.ATMFrame;
import application.Receipt;
import application.Withdraw;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

import java.io.IOException;
import java.util.List;

public class SuccessController {
    Parent tp;
    @FXML
    private TextArea receipt;
    public void Back() {
        try {
            tp = FXMLLoader.load(getClass()
                    .getResource("../fxml/Main.fxml"));
            Scene tpScene = new Scene(tp);
            ATMFrame.stage.setScene(tpScene);

        } catch (IOException e1) {
            System.out.println("执行出错");
            e1.printStackTrace();
        }
    }
    public void Exit() {
        ATM.exit();
        try {
            tp = FXMLLoader.load(getClass()
                    .getResource("../fxml/Login.fxml"));
            Scene tpScene = new Scene(tp);
            ATMFrame.stage.setScene(tpScene);

        } catch (IOException e1) {
            System.out.println("执行出错");
            e1.printStackTrace();
        }
    }
    public void Continue() {
        try {
            tp = FXMLLoader.load(getClass()
                    .getResource("../fxml/Deposit.fxml"));
            Scene tpScene = new Scene(tp);
            ATMFrame.stage.setScene(tpScene);

        } catch (IOException e1) {
            System.out.println("执行出错");
            e1.printStackTrace();
        }
    }
    public void Receipt() {
        List<Withdraw> withdraws;
        withdraws=ATM.askForPrintReceipt();
        receipt.setText("账户："+withdraws.get(0).getAccount().getCardId()+"   时间："+withdraws.get(0).getDate()+"  金额："+withdraws.get(0).getAmount());
    }
}
